package 算法

object FlipStr {
  def main(args: Array[String]): Unit = {
    val value = List[Int](1, 2, 3, 4)
    println(sum(value))
  }

  def sum(l: List[Int]): Int = {
    l.sum
  }

  def sum2(l: List[Int]): Int = {
    if (l.length <= 1) {
      l.headOption getOrElse 0
    } else {
      val tuple = l.splitAt(l.length / 2)
      sum(tuple._1) + sum(tuple._2)
    }
  }
}
